package cloudspace.controlpanel.submitter;

import org.webcat.submitter.targets.SubmissionTarget;
import org.zkoss.zul.Treecell;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.TreeitemRenderer;
import org.zkoss.zul.Treerow;


public class SubmissionTreeitemRenderer implements TreeitemRenderer
{
    // ----------------------------------------------------------
    public void render( Treeitem item, Object data ) throws Exception
    {

        SubmissionTarget target = (SubmissionTarget)data;

        Treecell cell = new Treecell( target.getName().trim() );
        Treerow tr;

        if ( item.getTreerow() == null )
        {
            tr = new Treerow();
            tr.setParent( item );
        }
        else
        {
            tr = item.getTreerow();
            tr.getChildren().clear();
        }

        cell.setParent( tr );
        item.setValue( target );
        item.setOpen( false );
    }
}
